#include<iostream>
using namespace std;
const int N = 100010;
int n, m;
int arr[N], sum[N];
int main() 
{
	cin >> n >> m;
	for (int i = 1; i < n+1; i++)
	{
		cin >> arr[i];
		sum[i] = sum[i - 1] + arr[i];
	}
	while (m--)
	{
		int l, r;
		cin >> l >> r;
		cout << sum[r] - sum[l - 1] << endl;
	}
	return 0;
}